#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    vector<string> in_num;
    cin>>n;
    string max_str;
    for(int i=0;i<n;i++)
    {
        string temp;
        cin>>temp;
        in_num.push_back(temp);
    }
    sort(in_num.begin(), in_num.end(), [](string s1, string s2){ return (s1+s2) < (s2+s1);
    });
    for (auto s:in_num) {
        cout << s;
    }
}